﻿using System;
using Microsoft.EntityFrameworkCore.Migrations;

#nullable disable

namespace EmployeeLeaveSystem.Server.Migrations
{
    /// <inheritdoc />
    public partial class Init8 : Migration
    {
        /// <inheritdoc />
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.CreateTable(
                name: "AddMoves",
                columns: table => new
                {
                    Id = table.Column<int>(type: "int", nullable: false)
                        .Annotation("SqlServer:Identity", "1, 1"),
                    StaffId = table.Column<int>(type: "int", nullable: true),
                    Created = table.Column<DateTime>(type: "datetime2", nullable: true),
                    ToDepartmentId = table.Column<int>(type: "int", nullable: true),
                    Reason = table.Column<string>(type: "nvarchar(max)", nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_AddMoves", x => x.Id);
                    table.ForeignKey(
                        name: "FK_AddMoves_Departments_ToDepartmentId",
                        column: x => x.ToDepartmentId,
                        principalTable: "Departments",
                        principalColumn: "Id");
                    table.ForeignKey(
                        name: "FK_AddMoves_StaffInfos_StaffId",
                        column: x => x.StaffId,
                        principalTable: "StaffInfos",
                        principalColumn: "Id");
                });

            migrationBuilder.CreateTable(
                name: "AddRetireMoves",
                columns: table => new
                {
                    Id = table.Column<int>(type: "int", nullable: false)
                        .Annotation("SqlServer:Identity", "1, 1"),
                    StaffId = table.Column<int>(type: "int", nullable: true),
                    Created = table.Column<DateTime>(type: "datetime2", nullable: true),
                    RetireDate = table.Column<DateTime>(type: "datetime2", nullable: true),
                    Reason = table.Column<string>(type: "nvarchar(max)", nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_AddRetireMoves", x => x.Id);
                    table.ForeignKey(
                        name: "FK_AddRetireMoves_StaffInfos_StaffId",
                        column: x => x.StaffId,
                        principalTable: "StaffInfos",
                        principalColumn: "Id");
                });

            migrationBuilder.CreateTable(
                name: "FileInfos",
                columns: table => new
                {
                    Id = table.Column<int>(type: "int", nullable: false)
                        .Annotation("SqlServer:Identity", "1, 1"),
                    FileName = table.Column<string>(type: "nvarchar(max)", nullable: true),
                    StaffId = table.Column<int>(type: "int", nullable: true),
                    AddMoveDepartmentId = table.Column<int>(type: "int", nullable: true),
                    AddRetireMoveId = table.Column<int>(type: "int", nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_FileInfos", x => x.Id);
                    table.ForeignKey(
                        name: "FK_FileInfos_AddMoves_AddMoveDepartmentId",
                        column: x => x.AddMoveDepartmentId,
                        principalTable: "AddMoves",
                        principalColumn: "Id");
                    table.ForeignKey(
                        name: "FK_FileInfos_AddRetireMoves_AddRetireMoveId",
                        column: x => x.AddRetireMoveId,
                        principalTable: "AddRetireMoves",
                        principalColumn: "Id");
                    table.ForeignKey(
                        name: "FK_FileInfos_StaffInfos_StaffId",
                        column: x => x.StaffId,
                        principalTable: "StaffInfos",
                        principalColumn: "Id");
                });

            migrationBuilder.CreateIndex(
                name: "IX_AddMoves_StaffId",
                table: "AddMoves",
                column: "StaffId");

            migrationBuilder.CreateIndex(
                name: "IX_AddMoves_ToDepartmentId",
                table: "AddMoves",
                column: "ToDepartmentId");

            migrationBuilder.CreateIndex(
                name: "IX_AddRetireMoves_StaffId",
                table: "AddRetireMoves",
                column: "StaffId");

            migrationBuilder.CreateIndex(
                name: "IX_FileInfos_AddMoveDepartmentId",
                table: "FileInfos",
                column: "AddMoveDepartmentId");

            migrationBuilder.CreateIndex(
                name: "IX_FileInfos_AddRetireMoveId",
                table: "FileInfos",
                column: "AddRetireMoveId");

            migrationBuilder.CreateIndex(
                name: "IX_FileInfos_StaffId",
                table: "FileInfos",
                column: "StaffId");
        }

        /// <inheritdoc />
        protected override void Down(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropTable(
                name: "FileInfos");

            migrationBuilder.DropTable(
                name: "AddMoves");

            migrationBuilder.DropTable(
                name: "AddRetireMoves");
        }
    }
}
